﻿using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                int a, b, result = 0;
                char c;
                string s = "";
                Console.WriteLine("请输入第一个操作数");
                s = Console.ReadLine();
                a = Int32.Parse(s);
                Console.WriteLine("请输入第二个操作数");
                s = Console.ReadLine();
                b = Int32.Parse(s);
                Console.WriteLine("请输入操作符");
                s = Console.ReadLine();
                c = s[0];
                switch (c)
                {
                    case '+': result = a + b; break;
                    case '-': result = a - b; break;
                    case '*': result = a * b; break;
                    case '/': result = a / b; break;
                }
                Console.WriteLine($"结果为{result}");
            }
            catch (System.FormatException)
            {
                Console.WriteLine("输入格式不正确"); return;
            }
            catch (DivideByZeroException)
            {
                Console.WriteLine("除数不得为0"); return;
            }


        }
    }
}
